package com.dragon.repository.domain.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.dragon.common.model.Update;
import com.dragon.common.util.BeanUtils;
import com.dragon.repository.entity.QuotesProducts;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

import javax.validation.constraints.NotNull;
import java.util.ArrayList;
import java.util.List;


/**
 * @author sy
 */
@Data
@ApiModel(value = "")
public class QuotesProductsVO {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Integer id;

    @ApiModelProperty(value = "供应商产品id")
    private Integer productsId;

    @ApiModelProperty(value = "报价id")
    private Integer quotesId;

    @ApiModelProperty(value = "数量")
    private Integer num;

    @ApiModelProperty(value = "总价")
    private Double price;

    @ApiModelProperty(value = "单价")
    private Double onePrice;

    @ApiModelProperty(value = "单位名称")
    private String unitName;

    @ApiModelProperty(value = "产品名称")
    private String name;

    @ApiModelProperty(value = "备注")
    private Double remark;

    @ApiModelProperty(value = "材质")
    private String material;


    @NotNull(groups = Update.class,message = "主键不能为空")
    public static QuotesProducts convert(QuotesProductsVO vo) {
        QuotesProducts entity = new QuotesProducts();
        BeanUtils.copyProperties(vo,entity);
        return entity;
    }
    public static List<QuotesProducts> convertList(List<QuotesProductsVO> list) {
        List<QuotesProducts> resultList = new ArrayList<>();
        for (QuotesProductsVO vo : list) {
            resultList.add(convert(vo));
        }
        return resultList;
    }
}
